namespace ::

entry {
    ShowWindow({
        @use text = State('Foo'),
        @use view = Label(text.$),
        @use edit = PlainButton('Edit'),
        @use Effect(text | bind-override(edit.Clicks | map-to-latest-from(text.$) | exhaust-map({ text =>
            ShowDialog({
                @use buf = TextBox(text),
                @use ok = PlainButton('OK'),
                @use cancel = PlainButton('Cancel'),
                Dialog(
                    $('Edit Text'),
                    Column(buf.Widget, Row(ok.Widget, cancel.Widget)),
                    { closes => {
                        let ok = Merge(buf.Enters, ok.Clicks),
                        let cancel = Merge(closes, cancel.Clicks),
                        ((ok map-to-latest-from buf.Text) take-until cancel)
                    }}
                )
            })
        }))),
        Window($('Dialog'), Column(view.Widget, edit.Widget))
    })
}


